package com.allwees.core.common.parser.el;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.aop.support.AopUtils;

import java.lang.reflect.Method;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ExpressionInteractiveObject {

    private Method method;

    private Object[] args;

    private Object target;

    private Object result;

    public ExpressionInteractiveObject(Method method, Object[] args,  Object target) {
        this.method = method;
        this.args = args;
        this.target = target;
    }

    public ParseExpressionRootObject rootObject() {
        return new ParseExpressionRootObject(method, args, target, method.getDeclaringClass(), AopUtils.getTargetClass(target));
    }
}
